﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using ModuleDALCore;
namespace DAL
{
    public class BANGCAPDAO:DALBase
    {
        public BANGCAPDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPBANGCAP"; }
            set { _SpName = value; }
        }
        public DataTable GetListBC()
        {
            dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new BANGCAP(), null), ConvertClassToArray.GetValues(new BANGCAP(), 0));
				return dt;
			}
			catch { return null; }
        }
		public List<BANGCAP> GetListBCS()
		{
			dt = new DataTable();
			List<BANGCAP> bc = new List<BANGCAP>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new BANGCAP(), null), ConvertClassToArray.GetValues(new BANGCAP(), 0));
				bc = (List<BANGCAP>)ConvertDatatableToList.ConvertTo<BANGCAP>(dt);
				return bc;
			}
			catch { return null; }
		}
        public String CreatenewId()
        {
            try
            {
                return "BC" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new BANGCAP(), null), ConvertClassToArray.GetValues(new BANGCAP(), 1));

            }
			catch { return null;}
        }
        public bool INSERT(BANGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }
        }
        public bool UPDATE(BANGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false;}
        }
        public bool DELETE(BANGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) ==1);

            }
			catch { return false;}
        }
    }
}
